<template>
  <div class="app-container">
    <div>
      <Find @Launchform="Launchform5" :formList="formList" @findClicked="findClicked5" />
      <Find :OriginalFilter="{ static: true }" @findClicked="findClicked1" :searchImg="false" @Launchform="Launchform6" :formList="formList1" />
    </div>

    <el-card style="margin-top: 15px" shadow="never" :body-style="{ padding: '13px' }">
      <div style="display: flex">
        <div style="width: 20%">
          <span style="font-weight: 600">待计算指令</span>
          <span class="f14" style="color: red"> &nbsp;PS:绿色代表该品牌已定义包材</span>
          <Table
            @sortChange="HeaderList"
            @selectList="selectList12"
            :isLoading="isLoading"
            :tableHeader="tableHeader"
            :tableData="ToBeInstructedTableDate"
            selection
            :TableHeight="97"
          />
          <PageModule
            :PageData="{ total, buttonS: true, pageSizeShow: true }"
            :layout="'prev, pager'"
            @pageSizeChange="handleSizeChangeTk"
            @pageChange="handleCurrentChangeTk"
          />
        </div>

        <div style="margin-left: 20px; width: 25%">
          <span style="font-weight: 600">已处理指令</span>
          <Table
            @sortChange="HeaderList1"
            @currentRow="clicktogetdata"
            :isLoading="isLoading2"
            :tableHeader="tableHeader2"
            :tableData="RegeneratedInstructionUnitPriceTableDate"
            :TableHeight="97"
          ></Table>
          <PageModule
            :PageData="{ total: totalL, buttonS: true, pageSizeShow: true }"
            :layout="'prev, pager'"
            @pageSizeChange="handleSizeChangeTk1"
            @pageChange="handleCurrentChangeTk1"
          />
        </div>

        <div style="margin-left: 20px; width: 50%">
          <span style="font-weight: 600">指令包材明细 </span>
          <span class="f14" style="color: red"> &nbsp;PS:1.双击物料编码或材料名称可以替换材料； 2.绿色代表材料已经采购或入库，不能更新&删除)</span>

          <TangTable
            class="TangTable"
            @selectValChange="confirmChange5"
            @inputChange="confirmChange5"
            @toBottom="toBottom"
            @toUp="toUp"
            @currentRow1="clicktogetdata5"
            @currentRow="clicktogetdata12"
            @selectList="selectList1"
            :mtlNoBooleenad="true"
            :isLoading="isLoading1"
            :tableHeader="tableHeader3"
            :tableData="CommandPackageDetailsQueryTableDate"
            selection
            :TableHeight="97"
          ></TangTable>
        </div>
      </div>
    </el-card>
    <!-- 新增待订购明细 -->
    <el-dialog :close-on-click-modal="false" v-model="dialogVisible7" width="50%">
      <Find :OriginalFilter="{ static: true }" :searchImg="false" @Launchform="Launchform3" :formList="formList3" @findClicked="findClicked3" />
      <Table
        @currentRow="clicktogetdata1"
        @currentRow1="currentRowList1"
        :isLoading="isLoading3"
        :tableHeader="tableHeader4"
        :tableData="NewOrderDetailsTableDate"
        :TableHeight="34"
      />
      <PageModule :PageData="{ buttonS: true, total: totalList1 }" @pageChange="pageChange11" @pageSizeChange="pageSizeChange11" />
      <h1 style="margin-top: 15px; color: black; font-size: 16px">物料资料建档</h1>
      <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList5" @Launchform="Launchform7" @findClicked="findData5" />
    </el-dialog>

    <!-- 新增待订购明细 -->
    <el-dialog :close-on-click-modal="false" v-model="dialogVisible8" width="50%">
      <Find @findClicked="findClicked7" :searchImg="false" @Launchform="Launchform8" :formList="formList7" />
      <Table
        @selectList="selectList3"
        selection
        style="width: 60%"
        :isLoading="isLoading5"
        :tableHeader="tableHeader5"
        :tableData="RegeneratedInstructionUnitPriceTableDate1"
        :TableHeight="70"
      ></Table>
      <PageModule
        :PageData="{ total: totalL1, buttonS: true, pageSizeShow: true }"
        @pageSizeChange="handleSizeChangeTk12"
        @pageChange="handleCurrentChangeTk12"
      />
    </el-dialog>

    <!-- 新增待订购明细 -->
    <el-dialog :close-on-click-modal="false" v-model="dialogVisible10" width="50%">
      <Find :OriginalFilter="{ static: true }" :searchImg="false" @Launchform="Launchform10" :formList="formList10" @findClicked="findClicked3" />
      <Table
        @currentRow="clicktogetdata1"
        @currentRow1="currentRowList8"
        :isLoading="isLoading3"
        :tableHeader="tableHeader15"
        :tableData="NewOrderDetailsTableDate"
        :TableHeight="34"
      />
      <PageModule :PageData="{ buttonS: true, total: totalList1 }" @pageChange="pageChange11" @pageSizeChange="pageSizeChange11" />
    </el-dialog>
  </div>
</template>
<script lang="ts">
import { defineComponent, ref, onMounted, onUnmounted } from 'vue'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'InstructionCalculation'
})
</script>
<script lang="ts" setup>
import { styleQuery } from '@/api/Control/FactoryControl/FormingPre'
import { AddBrandDate } from '@/api/PurchasingDepartment/FactoryPurchasing/BrandPackaging'
import { useRouter } from 'vue-router'
import {
  DependentInstruction,
  BatchAddPackagingMaterials,
  batchModifying,
  MaterialReplacement,
  ToBeInstructed,
  RegeneratedInstructionUnitPrice,
  CommandPackageDetailsQuery,
  deleteTick,
  BlockDeletion,
  AddBlock,
  GeneratedMaterialCodingList,
  TickToCalculateDosage,
  EmptyMaterialNumber,
  TickToCopyMaterial,
  sizeQuery
} from '@/api/PurchasingDepartment/FactoryPurchasing/lnstructionPackage'
import { packingMaterials } from '@/api/PurchasingDepartment/FactoryPurchasing/PackagingMaterialCategoryDefinition'
import {
  AddGeneratedMaterialCoding,
  dbClickAdd,
  GeneratedMaterialCoding,
  lotNoListQuery,
  MaterialClassificationQuery,
  NewOrderDetails
} from '@/api/PurchasingDepartment/FactoryPurchasing/PackagingMaterialsOtherOrder'
import LoginWork from '@/utils/LoginWork'
import { ElMessage, ElMessageBox } from 'element-plus'
import { watch } from 'vue'
import { forEach, sortBy } from 'lodash'
// 依托指令
const lotNoListA = ref('')

const DependentInstructionMethods = async () => {
  try {
    const result = await DependentInstruction(lotNoListA.value)
    if (result.code === 200) {
      dialogVisible7.value = false
      CommandPackageDetailsQueryMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('出错')
  }
}

// 材料收集
const TyleNameList = ref([])

// 添加包材
const BatchAddPackagingMaterialsTableDate = ref([])

const BatchAddPackagingMaterialsMethods = async () => {
  try {
    const result = await BatchAddPackagingMaterials(
      AddBlockParms.value.lotNo,
      BatchAddPackagingMaterialsTableDate.value.map((item: any) => {
        item.size1 = item.size1.selectValue
        item.size2 = item.size2.selectValue
        item.typeName = item.typeName.selectValue
        return item
      })
    )
    if (result.code === 200) {
      CommandPackageDetailsQueryMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('批量添加包材出错')
  }
}

// 保存修改
const batchModifyingMethods = async () => {
  const batchTableDate = CommandPackageDetailsQueryTableDate.value.map((item: any) => {
    item.size1 = item.size1.selectValue
    item.size2 = item.size2.selectValue
    // const values = item.typeName.selectValue.split(' ');

    // item.typeName = item.typeName.selectValue[1]
    // if (Array.isArray(values)) {
    //   item.typeName = item.typeName.selectValue.split(' ')[1]
    // } else {
    item.typeName = item.typeName.selectValue
    // }

    return item
  })
  try {
    const result = await batchModifying(batchTableDate)
    if (result.code === 200) {
      CommandPackageDetailsQueryMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('保存失败请重试')
  }
}

const toUp = (event: any, rowIndex: number, row: any) => {
  // 直接使用 rowIndex 获取元素
  const element = row.data[rowIndex + 1]

  if (element) {
    console.log('找到元素:', element) // 输出找到的元素

    // 计算下一个行索引
    const nextRowIndex = rowIndex + 1

    // 确保下一个索引在范围内
    if (nextRowIndex < CommandPackageDetailsQueryTableDate.value.length) {
      // 通过 v-for 中的 :ref 属性获取下一个输入框
      const nextInput = document.getElementById(`input-${rowIndex + 1}`)

      if (nextInput) {
        ;(nextInput as HTMLInputElement).focus() // 将焦点设置到下一个输入框
      }
    } else {
    }
  } else {
  }
}

const toBottom = (event: any, rowIndex: any, row: any) => {
  // 直接使用 rowIndex 获取元素
  const element = row.data[rowIndex + 1]

  console.log('找到元素:', element) // 输出找到的元素

  // 计算下一个行索引
  const nextRowIndex = rowIndex + 1

  // 确保下一个索引在范围内
  // 通过 v-for 中的 :ref 属性获取下一个输入框
  const nextInput = document.getElementById(`input-${rowIndex - 1}`)

  if (nextInput) {
    ;(nextInput as HTMLInputElement).focus() // 将焦点设置到下一个输入框
  }
}

const isLoading = ref(true)

const isLoading1 = ref(true)

const isLoading2 = ref(true)

const dialogVisible7 = ref(false)

const clicktogetdata5parms = ref()

const dialogVisible8 = ref(false)

const isLoading5 = ref(true)

const dialogVisible10 = ref(false)

// 号码查询
const sizeQueryParms = ref('')

const sizeQueryTableDate = ref([])

const sizeQueryMethods = async () => {
  let data = []
  const result = await sizeQuery(sizeQueryParms.value)
  data = result.filter((item: any) => item !== null)

  sizeQueryTableDate.value = EvaluatesTheArrayReturnValue1(data)
}

const currentRowList8 = (row: any) => {
  AddGeneratedMaterialCodingParms.value.mtlNo = row[0].inputValue
  AddGeneratedMaterialCodingParms.value.mtlName = row[1].inputValue
  AddGeneratedMaterialCodingParms.value.mtlUnit = row[2].inputValue
  AddGeneratedMaterialCodingParms.value.mtlType = row[3].selectValue.split(' ')[0]
  AddGeneratedMaterialCodingParms.value.mtlTypeName = row[3].selectValue.split(' ')[1]
  AddGeneratedMaterialCodingParms.value.mtlSpec = row[4].inputValue
  AddGeneratedMaterialCodingParms.value.mtlColor = row[5].inputValue
  AddGeneratedMaterialCodingParms.value.grossWeight = row[6].inputValue
  AddGeneratedMaterialCodingParms.value.netWeight = row[7].inputValue
}

// 材料替换
const clicktogetdata5 = (row: any, e: any) => {
  // storagedFlag === 'Y' || item.purchasedFlag
  if (e === 'mtlNo' && row.storagedFlag !== 'Y' && row.purchasedFlag !== 'Y') {
    dialogVisible7.value = true
    NewOrderDetailsMethods()
    MaterialReplacementParms.value.detail = row
    // MaterialReplacementParms.value.detail.typeName = row.typeName.selectValue
  }

  if (e === 'mtlName' && row.storagedFlag !== 'Y' && row.purchasedFlag !== 'Y') {
    dialogVisible10.value = true
    NewOrderDetailsMethods()
    MaterialReplacementParms.value.detail = row
  }
}

const MaterialReplacementParms = ref<any>({
  detail: {},
  materialData: {}
})

const MaterialReplacementMethods = async () => {
  MaterialReplacementParms.value.detail.typeName = MaterialReplacementParms.value.detail.typeName.selectValue
  MaterialReplacementParms.value.detail.size1 = MaterialReplacementParms.value.detail.size1.selectValue
  MaterialReplacementParms.value.detail.size2 = MaterialReplacementParms.value.detail.size2.selectValue
  const result = await MaterialReplacement(MaterialReplacementParms.value)
  if (result.code === 200) {
    CommandPackageDetailsQueryMethods()
    dialogVisible7.value = false
    dialogVisible10.value = false
    MaterialReplacementParms.value.materialData = {}
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const claerInputValueAndSelectValue1 = () => {
  formList7.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
  })
}

const Launchform8 = (row: any) => {
  RegeneratedInstructionUnitPriceParms1.value.lotNo = row[0].inputValue
  RegeneratedInstructionUnitPriceParms1.value.style = row[1].inputValue
  RegeneratedInstructionUnitPriceParms1.value.shipment = row[2].inputValue
  RegeneratedInstructionUnitPriceMethods1()
}

const findClicked7 = (count: string) => {
  if (count === '置空') {
    claerInputValueAndSelectValue1()
  }
  if (count === '复制到打勾指令') {
    if (TickToCopyMaterialParms.value.lotNoList.length === 0) {
      JMessage.warning('请选择需要复制的数据')
    } else {
      TickToCopyMaterialMethods()
    }
  }
}

// 打勾复制材料
const TickToCopyMaterialParms = ref({
  detailList: [],
  lotNoList: []
})

const selectList3 = (row: any) => {
  TickToCopyMaterialParms.value.lotNoList = row.map((item: any) => {
    return item
  })
}

const TickToCopyMaterialMethods = async () => {
  // TickToCopyMaterialParms.value.lotNoList.map((item: any) => {
  //   item.lotNo = GeneratedMaterialCodingListMethodsParms.value.lotNo
  //   item.style = GeneratedMaterialCodingListMethodsParms.value.style
  //   item.shipment = GeneratedMaterialCodingListMethodsParms.value.shipment
  //   // item.typeName = item.typeName.selectValue
  //   return item
  // })

  TickToCopyMaterialParms.value.detailList.map((item: any, index: number) => {
    item.typeName = TyleNameList.value[index]
    item.size1 = item.size1.selectValue
    item.size2 = item.size2.selectValue
    return item
  })
  const result = await TickToCopyMaterial(TickToCopyMaterialParms.value)
  if (result.code === 200) {
    dialogVisible8.value = false
    CommandPackageDetailsQueryMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const EmptyMaterialNumberMethods = async () => {
  const result = await EmptyMaterialNumber(GeneratedMaterialCodingListMethodsParms.value)
  if (result.code === 200) {
    CommandPackageDetailsQueryMethods()
    JMessage.success(result.message)
  } else {
    ToBeInstructedMethods()
    JMessage.error(result.message)
  }
}

// 打勾计算用量
const TickToCalculateDosageTableDate = ref([])

const selectList12 = (row: any) => {
  TickToCalculateDosageTableDate.value = row.map((item: any) => {
    return item
  })
}

const findClicked5 = (count: string) => {
  if (count === '打勾计算用量') {
    let active = false
    TickToCalculateDosageTableDate.value.map((item: any) => {
      if (item.packedFlag !== 'Y') {
        active = true
      }
      return item
    })
    if (!active) {
      if (TickToCalculateDosageTableDate.value.length === 0) {
        JMessage.warning('请勾选需要计算的数据')
      } else {
        TickToCalculateDosageMethods()
      }
    } else {
      JMessage.warning('请勾选绿色数据进行计算')
    }
  }
}

const TickToCalculateDosageMethods = async () => {
  const result = await TickToCalculateDosage(TickToCalculateDosageTableDate.value)
  if (result.code === 200) {
    TickToCalculateDosageTableDate.value = []
    ToBeInstructedMethods()
    RegeneratedInstructionUnitPriceMethods()
    JMessage.success(result.message)
  } else {
    ToBeInstructedMethods()
    JMessage.error(result.message)
  }
}

// 生成物料编码
const GeneratedMaterialCodingListMethodsParms = ref({
  lotNo: '',
  mtlColor: '',
  mtlName: '',
  mtlNo: '',
  mtlSpec: '',
  mtlUnit: '',
  packType: '',
  packedFlag: '',
  pageNum: '',
  pageSize: '',
  shipment: '',
  size1: '',
  size2: '',
  style: '',
  typeName: '',
  usage: '',
  id: '',
  purchasedFlag: '',
  storagedFlag: '',
  seqNo: '',
  TypeName: '',
  mtlType: ''
})

const clicktogetdata12 = (row: any) => {
  GeneratedMaterialCodingListMethodsParms.value.mtlColor = row.mtlColor
  GeneratedMaterialCodingListMethodsParms.value.mtlName = row.mtlName
  GeneratedMaterialCodingListMethodsParms.value.mtlSpec = row.mtlSpec
  GeneratedMaterialCodingListMethodsParms.value.mtlUnit = row.mtlUnit
  GeneratedMaterialCodingListMethodsParms.value.mtlNo = row.mtlNo
  GeneratedMaterialCodingListMethodsParms.value.size1 = row.size1.selectValue
  GeneratedMaterialCodingListMethodsParms.value.size2 = row.size2.selectValue
  GeneratedMaterialCodingListMethodsParms.value.typeName = row.typeName.selectValue
  GeneratedMaterialCodingListMethodsParms.value.id = row.id
  GeneratedMaterialCodingListMethodsParms.value.purchasedFlag = row.purchasedFlag
  GeneratedMaterialCodingListMethodsParms.value.storagedFlag = row.storagedFlag
  GeneratedMaterialCodingListMethodsParms.value.seqNo = row.seqNo
}

const GeneratedMaterialCodingListMethods = async () => {
  const result = await GeneratedMaterialCodingList(GeneratedMaterialCodingListMethodsParms.value)
  if (result.code === 200) {
    GeneratedMaterialCodingListMethodsParms.value.mtlNo = ''
    CommandPackageDetailsQueryMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 修改包材资料
const confirmChange5 = async (row?: any) => {
  row.size1 = row.size1.selectValue
  row.size2 = row.size2.selectValue
  if (row.typeName.selectValue && row.typeName.selectValue.includes(' ')) {
    const splitValues = row.typeName.selectValue.split(' ')
    row.typeName = splitValues[1]
    row.seqNo = splitValues[0]
  } else {
    row.typeName = row.typeName.selectValue
  }

  const result = await LoginWork.post<any, any>('/InstructionPackagingMaterial/updateInstructionPackageDetails', row)
  if (result.code === 200) {
    dialogVisible7.value = false
    CommandPackageDetailsQueryMethods()
    // JMessage.success(result.message)
  } else {
    // CommandPackageDetailsQueryMethods()
    JMessage.error(result.message)
  }
}

// 添加包材
const AddBlockParms = ref<any>({
  lotNo: '',
  mtlColor: '',
  mtlName: '',
  mtlNo: '',
  mtlSpec: '',
  mtlUnit: '',
  packType: '',
  packedFlag: '',
  pageNum: '',
  pageSize: '',
  shipment: '',
  size1: '',
  size2: '',
  style: '',
  typeName: '',
  usage: '',
  seqNo: ''
})

const clicktogetdata1 = (row: any) => {
  clicktogetdata5parms.value = row
  MaterialReplacementParms.value.materialData = row
}

const AddBlockMethods = async () => {
  const result = await AddBlock(AddBlockParms.value)
  if (result.code === 200) {
    CommandPackageDetailsQueryMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 增加
const AddGeneratedMaterialCodingParms = ref({
  grossWeight: '',
  mtlColor: '',
  mtlName: '',
  mtlNo: '',
  mtlSpec: '',
  mtlType: '',
  mtlTypeName: '',
  mtlUnit: '',
  netWeight: ''
})

const findClicked3 = (count: string) => {
  if (count === '材料替换') {
    if (Object.keys(MaterialReplacementParms.value.materialData).length === 0) {
      JMessage.warning('请选择需要替换的数据')
    } else {
      MaterialReplacementMethods()
    }
  }
}

const selectList2 = (row: any) => {
  dbClickAddMethodsParms.value = row.map((item: any) => {
    return item
  })
}

// 新增
const formList3 = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '材料分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '规格',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '物料编码',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'button',
    checkboxLabel: '材料替换'
  }
])

const formList10 = ref([
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'button',
    checkboxLabel: '材料替换'
  }
])

// 双击料号新增
const dbClickAddMethodsParms = ref([])

const dbClickAddMethods = async () => {
  const result = await dbClickAdd(dbClickAddMethodsParms.value)
  if (result.code === 200) {
    ToBeInstructedMethods()
    dialogVisible7.value = false
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 新增订购明细查询
const NewOrderDetailsParms = ref({
  grossWeight: '',
  mtlColor: '',
  mtlName: '',
  mtlNo: '',
  mtlSpec: '',
  mtlType: '',
  mtlTypeName: '',
  mtlUnit: '',
  netWeight: '',
  pageNum: 1,
  pageSize: 40
})

const Launchform3 = (row: any) => {
  NewOrderDetailsParms.value.mtlType = row[0].selectValue.split(' ')[0]
  NewOrderDetailsParms.value.mtlTypeName = row[0].selectValue.split(' ')[1]
  NewOrderDetailsParms.value.mtlName = row[1].inputValue
  NewOrderDetailsParms.value.mtlSpec = row[2].inputValue
  NewOrderDetailsParms.value.mtlNo = row[3].inputValue
  NewOrderDetailsMethods()
}

const Launchform10 = (row: any) => {
  NewOrderDetailsParms.value.mtlName = row[0].inputValue
  NewOrderDetailsMethods()
}

const isLoading3 = ref(false)

const NewOrderDetailsTableDate = ref([])

const NewOrderDetailsMethods = async () => {
  isLoading3.value = true
  const result = await NewOrderDetails(NewOrderDetailsParms.value)
  NewOrderDetailsTableDate.value = result.lotNoList
  totalList1.value = result.total
  isLoading3.value = false
}

const totalList1 = ref(0)

const pageChange11 = (val: any) => {
  NewOrderDetailsParms.value.pageNum = val
  NewOrderDetailsMethods()
}

const pageSizeChange11 = (val: any) => {
  NewOrderDetailsParms.value.pageSize = val
  NewOrderDetailsMethods()
}

// 物料资料建档
const formList5 = ref([
  {
    type: 'input',
    inputPlaceholder: '物料编号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '品名',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '单位',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '规格',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '颜色',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '毛重',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '净重',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '清空'
  },
  {
    type: 'button',
    checkboxLabel: '生成物料编码'
  },
  {
    type: 'button',
    checkboxLabel: '增加'
  }
])

// 生成物料编码
const GeneratedMaterialCodingParms = ref({
  grossWeight: '',
  mtlColor: '',
  mtlName: '',
  mtlSpec: '',
  mtlType: '',
  mtlTypeName: '',
  mtlUnit: '',
  netWeight: '',
  mtlNo: ''
})

const GeneratedMaterialCodingMethods = async () => {
  const result = await GeneratedMaterialCoding(GeneratedMaterialCodingParms.value)
  if (result.code === 200) {
    formList5.value[0].inputValue = result.data.mtlNo
    JMessage.success(result.message)
  } else {
    NewOrderDetailsMethods()
    JMessage.error(result.message)
  }
}

const currentRowList1 = (row: any) => {
  formList5.value[1].inputValue = row.mtlName
  formList5.value[2].inputValue = row.mtlUnit
  formList5.value[3].selectValue = row.mtlType
  formList5.value[4].inputValue = row.mtlSpec
  formList5.value[5].inputValue = row.mtlColor
  formList5.value[6].inputValue = row.grossWeight
  formList5.value[7].inputValue = row.netWeight
}

const clearFormList1 = () => {
  formList5.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const AddGeneratedMaterialCodingMethods = async () => {
  const result = await AddGeneratedMaterialCoding(AddGeneratedMaterialCodingParms.value)
  if (result.code === 200) {
    clearFormList1()
    NewOrderDetailsMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const findData5 = (count: string) => {
  if (count === '生成物料编码') {
    GeneratedMaterialCodingMethods()
  }
  if (count === '清空') {
    clearFormList1()
  }
  if (count === '增加') {
    if (AddGeneratedMaterialCodingParms.value.mtlName === '' || AddGeneratedMaterialCodingParms.value.mtlNo === '') {
      JMessage.warning('物料编号物料名称颜色不可为空')
    } else {
      AddGeneratedMaterialCodingMethods()
    }
  }
}

const packingMaterialsMethodsTableDate = ref([])

const packingMaterialsMethods = async () => {
  const result = await packingMaterials()

  let array = result.lotNoList.map((item: any) => {
    delete item.id
    delete item.caluBase
    delete item.sizeFlag
    delete item.purFlag

    return item
  })

  const NewArrayList = array.reduce((arr: any, item: any) => {
    if (item.seqNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.seqNo + ' ' + item.typeName)
    }
    return arr
  }, [])

  packingMaterialsMethodsTableDate.value = EvaluatesTheArrayReturnValue1(NewArrayList)
}

const Launchform7 = (row: any) => {
  AddGeneratedMaterialCodingParms.value.mtlNo = row[0].inputValue
  AddGeneratedMaterialCodingParms.value.mtlName = row[1].inputValue
  AddGeneratedMaterialCodingParms.value.mtlUnit = row[2].inputValue
  AddGeneratedMaterialCodingParms.value.mtlType = row[3].selectValue.split(' ')[0]
  AddGeneratedMaterialCodingParms.value.mtlTypeName = row[3].selectValue.split(' ')[1]
  AddGeneratedMaterialCodingParms.value.mtlSpec = row[4].inputValue
  AddGeneratedMaterialCodingParms.value.mtlColor = row[5].inputValue
  AddGeneratedMaterialCodingParms.value.grossWeight = row[6].inputValue
  AddGeneratedMaterialCodingParms.value.netWeight = row[7].inputValue

  GeneratedMaterialCodingParms.value.mtlNo = row[0].inputValue
  GeneratedMaterialCodingParms.value.mtlName = row[1].inputValue
  GeneratedMaterialCodingParms.value.mtlUnit = row[2].inputValue
  GeneratedMaterialCodingParms.value.mtlType = row[3].selectValue.split(' ')[0]
  GeneratedMaterialCodingParms.value.mtlTypeName = row[3].selectValue.split(' ')[1]
  GeneratedMaterialCodingParms.value.mtlSpec = row[4].inputValue
  GeneratedMaterialCodingParms.value.mtlColor = row[5].inputValue
  GeneratedMaterialCodingParms.value.grossWeight = row[6].inputValue
  GeneratedMaterialCodingParms.value.netWeight = row[7].inputValue
}

// 整单删除
const lotNoList = ref('')

const BlockDeletionMethods = async () => {
  const result = await BlockDeletion(lotNoList.value)
  if (result.code === 200) {
    CommandPackageDetailsQueryMethods()
    RegeneratedInstructionUnitPriceMethods()
    ToBeInstructedMethods()
    lotNoList.value = ''
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const handleCloseMateriaLKlc1 = (_done?: () => void) => {
  if (lotNoList.value === '') {
    JMessage.warning('请选择需要删除的数据(已处理指令)')
  } else {
    ElMessageBox.confirm('确认要删除数据吗?')
      .then(async () => {
        BlockDeletionMethods()
      })
      .catch(() => {})
  }
}

// 删除包材明细资料
const deleteTickParms = ref([])

const selectList1 = (row: any) => {
  deleteTickParms.value = row.map((item: any) => {
    return item
  })

  TickToCopyMaterialParms.value.detailList = row.map((item: any) => {
    return item
  })

  BatchAddPackagingMaterialsTableDate.value = row.map((item: any) => {
    return item
  })

  TyleNameList.value = row.map((item: any) => {
    return item.typeName.selectValue
  })
}

const deleteTickMethods = async () => {
  const result = await deleteTick(
    deleteTickParms.value.map((item: any) => {
      item.typeName = item.typeName.selectValue
      item.size1 = item.typeName.size1
      item.size2 = item.typeName.size2
      return item
    })
  )
  if (result.code === 200) {
    CommandPackageDetailsQueryMethods()
    deleteTickParms.value = []
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const handleCloseMateriaLKlc = (_done?: () => void) => {
  if (deleteTickParms.value.length === 0) {
    JMessage.warning('请勾选需要删除的数据')
  } else {
    ElMessageBox.confirm('确认要删除数据吗?')
      .then(async () => {
        deleteTickMethods()
      })
      .catch(() => {})
  }
}

const findClicked1 = (row: any) => {
  if (row === '搜索') {
    RegeneratedInstructionUnitPriceMethods()
  }
  if (row === '更新鞋托') {
    DependentInstructionMethods()
  }
  if (row === '删除打勾材料') {
    handleCloseMateriaLKlc()
  }
  if (row === '删除包材用量（整单）') {
    handleCloseMateriaLKlc1()
  }
  if (row === '添加包材') {
    if (CommandPackageDetailsQueryTableDate.value.length > 0) {
      var lastIndex = CommandPackageDetailsQueryTableDate.value.length - 1
      AddBlockParms.value.mtlColor = CommandPackageDetailsQueryTableDate.value[lastIndex].mtlColor
      AddBlockParms.value.mtlName = CommandPackageDetailsQueryTableDate.value[lastIndex].mtlName
      AddBlockParms.value.mtlSpec = CommandPackageDetailsQueryTableDate.value[lastIndex].mtlSpec
      AddBlockParms.value.mtlUnit = CommandPackageDetailsQueryTableDate.value[lastIndex].mtlUnit
      AddBlockParms.value.typeName = CommandPackageDetailsQueryTableDate.value[lastIndex].typeName.selectValue
      AddBlockParms.value.mtlNo = CommandPackageDetailsQueryTableDate.value[lastIndex].mtlNo
      AddBlockParms.value.seqNo = CommandPackageDetailsQueryTableDate.value[lastIndex].seqNo
    } else {
      AddBlockParms.value.mtlColor = ''
      AddBlockParms.value.mtlName = ''
      AddBlockParms.value.mtlSpec = ''
      AddBlockParms.value.mtlUnit = ''
      AddBlockParms.value.typeName = '外箱'
      AddBlockParms.value.mtlNo = ''
      AddBlockParms.value.seqNo = 1
    }
    if (GeneratedMaterialCodingListMethodsParms.value.lotNo === '') {
      JMessage.warning('请选择已处理的指令数据')
    } else {
      BatchAddPackagingMaterialsMethods()
    }

    if (AddBlockParms.value.lotNo === '') {
      JMessage.warning('请先选择已处理指令')
    } else {
    }
  }
  if (row === '生成物料编码') {
    console.log(GeneratedMaterialCodingListMethodsParms.value)
    if (GeneratedMaterialCodingListMethodsParms.value.TypeName === undefined) {
      return JMessage.warning('请先选择材料分类')
    }
    if (GeneratedMaterialCodingListMethodsParms.value.lotNo === '') {
      JMessage.warning('请选择已处理的指令数据')
    } else {
      GeneratedMaterialCodingListMethods()
    }
  }
  if (row === '置空物料编码') {
    if (GeneratedMaterialCodingListMethodsParms.value.lotNo === '') {
      JMessage.warning('请选择已处理的指令数据')
    } else if (GeneratedMaterialCodingListMethodsParms.value.mtlNo === '') {
      JMessage.warning('请选择需要生成物料编码的数据')
    } else {
      EmptyMaterialNumberMethods()
    }
  }

  if (row === '打勾材料复制') {
    let hasEmptyMtlNo = false
    TickToCopyMaterialParms.value.detailList.map((item: any) => {
      if (item.mtlNo === '' || item.mtlNo === null) {
        hasEmptyMtlNo = true
      }
      return item
    })
    if (TickToCopyMaterialParms.value.detailList.length === 0) {
      JMessage.warning('请先勾需要复制的包材明细数据!!!')
    } else {
      dialogVisible8.value = true
      RegeneratedInstructionUnitPriceMethods1()
    }
  }

  if (row === '置空') {
    claerInputValueAndSelectValue()
  }

  if (row === '品牌定义>>') {
    router.push({
      path: '/PurchasingDepartment/FactoryPurchasing/BrandPackaging'
    })
  }

  if (row === '保存全部指令包材明细') {
    // batchModifyingMethods()
    // handleCloseMateriaLKlc15()
  }
}

watch(
  () => GeneratedMaterialCodingListMethodsParms.value.lotNo,
  (oldValue) => {
    if (CommandPackageDetailsQueryTableDate.value.length > 0) {
      // batchModifyingMethods()
    }
  }
)
const handleCloseMateriaLKlc15 = (_done?: () => void) => {
  ElMessageBox.confirm('是否要保存指令“' + GeneratedMaterialCodingListMethodsParms.value.lotNo + '”包材明细的数据?')
    .then(async () => {
      // batchModifyingMethods()
    })
    .catch(() => {
      // ElMessageBox.confirm(JSON.stringify(GeneratedMaterialCodingListMethodsParms.value.lotNo))
    })
}
const router = useRouter()

const claerInputValueAndSelectValue = () => {
  formList1.value.forEach((item) => {
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

// 材料分类查询
const MaterialClassificationQueryMethods = async () => {
  const result = await MaterialClassificationQuery()
  const NewArrayList = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])

  formList3.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  formList5.value[3].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  formList1.value[5].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}

// 包材明细查询
const CommandPackageDetailsQueryParms = ref({
  lotNo: '',
  shipment: '',
  style: ''
})

const clicktogetdata = (row: any) => {
  CommandPackageDetailsQueryParms.value.shipment = row.shipment
  CommandPackageDetailsQueryParms.value.style = row.style
  lotNoListA.value = row.lotNo
  CommandPackageDetailsQueryParms.value.lotNo = row.lotNo
  CommandPackageDetailsQueryMethods()

  lotNoList.value = row.lotNo

  AddBlockParms.value.lotNo = row.lotNo
  AddBlockParms.value.style = row.style
  AddBlockParms.value.shipment = row.shipment

  GeneratedMaterialCodingListMethodsParms.value.lotNo = row.lotNo
  GeneratedMaterialCodingListMethodsParms.value.style = row.style
  GeneratedMaterialCodingListMethodsParms.value.shipment = row.shipment
  sizeQueryParms.value = row.style
  sizeQueryMethods()
}

const CommandPackageDetailsQueryTableDate = ref<any>([])

// const totalL13 = ref()

// const handleSizeChangeTk13 = (val: number) => {
//   CommandPackageDetailsQueryParms.value.pageSize = val
//   CommandPackageDetailsQueryMethods()
// }

// const handleCurrentChangeTk13 = (val: number) => {
//   CommandPackageDetailsQueryParms.value.pageNum = val
//   CommandPackageDetailsQueryMethods()
// }

const CommandPackageDetailsQueryMethods = async () => {
  isLoading1.value = true
  const result = await CommandPackageDetailsQuery(CommandPackageDetailsQueryParms.value)
  CommandPackageDetailsQueryTableDate.value = result.lotNoList.map((item: any) => {
    item.size1 = {
      selectValue: item.size1 || '',
      options: sizeQueryTableDate
    }
    item.size2 = {
      selectValue: item.size2 || '',
      options: sizeQueryTableDate
    }

    if (item.storagedFlag === 'Y' || item.purchasedFlag === 'Y') {
      item.change = 'Y'
      item.backgroundColor = '#3FFF38'
      item.disableConfirm = true
      item.typeName = {
        selectValue: item.typeName || '',
        options: packingMaterialsMethodsTableDate
      }
    } else {
      item.change = 'Y'
      item.disableConfirm = true
      item.typeName = {
        selectValue: item.typeName || '',
        options: packingMaterialsMethodsTableDate
      }
      item.change = 'Y'
    }

    // if(item.mtlNo === null || item.mtlNo === ''){
    //     item.change = 'Y'
    // }

    return item
  })
  tableHeader3.value.push()
  isLoading1.value = false
}

// 已处理指令查询
const RegeneratedInstructionUnitPriceParms = ref({
  lotNo: '',
  pageNum: 1,
  pageSize: 40,
  shipment: '',
  style: '',
  sort: 2
})

const Launchform6 = (row: any) => {
  RegeneratedInstructionUnitPriceParms.value.lotNo = row[0].selectValue
  RegeneratedInstructionUnitPriceParms.value.shipment = row[1].selectValue
  RegeneratedInstructionUnitPriceParms.value.style = row[2].selectValue

  GeneratedMaterialCodingListMethodsParms.value.TypeName = row[5].selectValue.split(' ')[1]
  GeneratedMaterialCodingListMethodsParms.value.mtlType = row[5].selectValue.split(' ')[0]
}

const RegeneratedInstructionUnitPriceTableDate = ref([])

const RegeneratedInstructionUnitPriceTableDate1 = ref([])

const RegeneratedInstructionUnitPriceParms1 = ref({
  lotNo: '',
  pageNum: 1,
  pageSize: 40,
  shipment: '',
  style: ''
})

const HeaderList1 = (a: any, b: any, c: any) => {
  if (a !== null) {
    RegeneratedInstructionUnitPriceParms.value.sort = a === 'ascending' ? 1 : 2
    RegeneratedInstructionUnitPriceMethods()
  }
}

const RegeneratedInstructionUnitPriceMethods1 = async () => {
  isLoading5.value = true
  const result = await RegeneratedInstructionUnitPrice(RegeneratedInstructionUnitPriceParms1.value)
  RegeneratedInstructionUnitPriceTableDate1.value = result.lotNoList
  totalL1.value = result.total
  isLoading5.value = false
}

const RegeneratedInstructionUnitPriceMethods = async () => {
  isLoading2.value = true
  const result = await RegeneratedInstructionUnitPrice(RegeneratedInstructionUnitPriceParms.value)
  RegeneratedInstructionUnitPriceTableDate.value = result.lotNoList
  if (result.lotNoList.length !== 0) {
    CommandPackageDetailsQueryParms.value.lotNo = result.lotNoList[0].lotNo
    CommandPackageDetailsQueryParms.value.shipment = result.lotNoList[0].shipment
    CommandPackageDetailsQueryParms.value.style = result.lotNoList[0].style

    AddBlockParms.value.lotNo = result.lotNoList[0].lotNo
    AddBlockParms.value.style = result.lotNoList[0].style
    AddBlockParms.value.shipment = result.lotNoList[0].shipment

    GeneratedMaterialCodingListMethodsParms.value.lotNo = result.lotNoList[0].lotNo
    lotNoListA.value = result.lotNoList[0].lotNo
    GeneratedMaterialCodingListMethodsParms.value.style = result.lotNoList[0].style
    GeneratedMaterialCodingListMethodsParms.value.shipment = result.lotNoList[0].shipment
    sizeQueryParms.value = result.lotNoList[0].style
    sizeQueryMethods()
    CommandPackageDetailsQueryMethods()
  }
  totalL.value = result.total
  isLoading2.value = false
}

const totalL = ref()

const handleSizeChangeTk1 = (val: number) => {
  RegeneratedInstructionUnitPriceParms.value.pageSize = val
  RegeneratedInstructionUnitPriceMethods()
}

const handleCurrentChangeTk1 = (val: number) => {
  RegeneratedInstructionUnitPriceParms.value.pageNum = val
  RegeneratedInstructionUnitPriceMethods()
}

const totalL1 = ref()

const handleSizeChangeTk12 = (val: number) => {
  RegeneratedInstructionUnitPriceParms1.value.pageSize = val
  RegeneratedInstructionUnitPriceMethods1()
}

const handleCurrentChangeTk12 = (val: number) => {
  RegeneratedInstructionUnitPriceParms1.value.pageNum = val
  RegeneratedInstructionUnitPriceMethods1()
}

const styleQueryMethods = async () => {
  let result = await styleQuery()

  formList1.value[2].selectOptions = EvaluatesTheArrayReturnValue(result.filter((item: any) => item !== null))
}

// 查询
const ToBeInstructedParms = ref({
  lotNo: '',
  pageNum: 1,
  pageSize: 40,
  shipment: '',
  style: '',
  sort: 2
})

const HeaderList = (a: any, b: any, c: any) => {
  if (a !== null) {
    ToBeInstructedParms.value.sort = a === 'ascending' ? 1 : 2
    ToBeInstructedMethods()
  }
}

const Launchform5 = (row: any) => {
  ToBeInstructedParms.value.lotNo = row[0].inputValue
  ToBeInstructedParms.value.style = row[1].inputValue
  ToBeInstructedParms.value.shipment = row[2].inputValue
  ToBeInstructedMethods()
}

const EvaluatesTheArrayReturnValue1 = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      value: item,
      label: item
    }
  })
}

const ToBeInstructedTableDate = ref([])

const ToBeInstructedMethods = async () => {
  isLoading.value = true
  const result = await ToBeInstructed(ToBeInstructedParms.value)
  ToBeInstructedTableDate.value = result.lotNoList.map((item: any) => {
    if (item.packedFlag === 'Y') {
      item.backgroundColor = '#3FFF38'
    }
    return item
  })
  total.value = result.total
  isLoading.value = false
}

const total = ref()

const handleSizeChangeTk = (val: number) => {
  ToBeInstructedParms.value.pageSize = val
  ToBeInstructedMethods()
}

const handleCurrentChangeTk = (val: number) => {
  ToBeInstructedParms.value.pageNum = val
  ToBeInstructedMethods()
}

onMounted(() => {
  ToBeInstructedMethods()

  RegeneratedInstructionUnitPriceMethods()

  lotNoListQueryMethods()

  styleQueryMethods()

  AddBrandDateMethods()

  packingMaterialsMethods()

  MaterialClassificationQueryMethods()
})

// 指令回显
const lotNoListQueryParms = ref({
  lotNo: '',
  pageSize: 40,
  pageNum: 1
})

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

const totalLo = ref(0)

const lotNoListQueryMethods = async () => {
  const result = await lotNoListQuery(lotNoListQueryParms.value)
  const NewArrayList = result.lotNoList.reduce((arr: any, item: any) => {
    if (item.lotNo) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.lotNo)
    }
    return arr
  }, [])
  totalLo.value = result.total
  formList1.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}

const handleSizeChange1 = (val: number) => {
  lotNoListQueryParms.value.pageSize = val
  lotNoListQueryMethods()
}
const handleCurrentChange1 = (val: number) => {
  lotNoListQueryParms.value.pageNum = val
  lotNoListQueryMethods()
}

// 下拉框数据
const AddBrandDateMethods = async () => {
  let NewArray = []
  const result = await AddBrandDate()
  NewArray = result.lotNoList.reduce((arr: any, item: any) => {
    if (item.style) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.style)
    }
    return arr
  }, [])
  formList1.value[1].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

const formList = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入型体',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入品牌',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'button',
    checkboxLabel: '打勾计算用量'
  }
  // {
  //   type: 'select',
  //   selectValue: '',
  //   selectP: '指令',
  //   selectLabel: '',
  //   selectOptions: [],
  // },
  // {
  //   type: 'select',
  //   selectValue: '',
  //   selectP: '品牌',
  //   selectLabel: '',
  //   selectOptions: [],
  // },
  // {
  //   type: 'select',
  //   selectValue: '',
  //   selectP: '型体',
  //   selectLabel: '',
  //   selectOptions: [],
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '查询（已计算）',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '添加包材',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '打勾材料复制',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '删除包材用量（整单）',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '删除打勾材料',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '生成物料编码',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '物料编码',
  // },
  // {
  //   type: 'button',
  //   checkboxLabel: '品牌定义',
  // },
])

const formList1 = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '指令',
    selectLabel: '',
    selectOptions: [],
    PageModule: true,
    total: totalLo,
    handleSizeChange: handleSizeChange1,
    handleCurrentChange: handleCurrentChange1
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '品牌',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '型体',
    selectLabel: '',
    selectOptions: []
  },
  // {
  //   type: 'button',
  //   checkboxLabel: '查询（已计算）',
  // },
  {
    type: 'button',
    checkboxLabel: '添加包材'
  },
  {
    type: 'button',
    checkboxLabel: '打勾材料复制'
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '材料分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'button',
    checkboxLabel: '生成物料编码'
  },
  {
    type: 'button',
    checkboxLabel: '删除打勾材料'
  },

  // {
  //   type: 'button',
  //   checkboxLabel: '物料编码',
  // },

  {
    type: 'button',
    checkboxLabel: '置空物料编码'
  },
  {
    type: 'button',
    checkboxLabel: '删除包材用量（整单）'
  },
  {
    type: 'button',
    checkboxLabel: '品牌定义>>'
  },

  {
    type: 'button',
    checkboxLabel: '更新鞋托',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '搜索',
    bgColor: '#1890FF'
  }

  // {
  //   type: 'button',
  //   checkboxLabel: '保存全部指令包材明细',bgColor:'#1890FF',
  // },
])

const formList7 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入型体',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入品牌',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'button',
    checkboxLabel: '复制到打勾指令'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const tableHeader = ref([
  {
    label: '指令',
    prop: 'lotNo',
    backgroundColor: true,
    sortable: true
  },
  {
    label: '品牌',
    prop: 'shipment'
  }
])

const tableHeader2 = ref([
  {
    label: '指令',
    prop: 'lotNo',
    sortable: true
  },
  {
    label: '型体',
    prop: 'style'
  },
  {
    label: '品牌',
    prop: 'shipment'
  },
  {
    label: '总箱数',
    prop: 'totalCartons'
  },
  {
    label: '订单数',
    prop: 'orderQty'
  }
])

const tableHeader5 = ref([
  {
    label: '指令',
    prop: 'lotNo'
  },
  {
    label: '型体',
    prop: 'style'
  },
  {
    label: '品牌',
    prop: 'shipment'
  },
  {
    label: '订单数',
    prop: 'orderQty'
  },
  {
    label: '指令箱数',
    prop: 'shipment'
  }
])

const tableHeader3 = ref([
  {
    label: '包材类别',
    prop: 'typeName',
    type: 'select'
  },
  {
    label: '物料编码',
    prop: 'mtlNo',
    change: true
  },
  {
    label: '颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称 ',
    prop: 'mtlName',
    backgroundColor: true,
    width: '200',
    start: true,
    type: 'mtlNoBooleenad'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '号码起',
    prop: 'size1',
    type: 'select'
  },
  {
    label: '号码止',
    prop: 'size2',
    type: 'select'
  },
  {
    label: '用量',
    prop: 'ttlUsage'
  },
  {
    label: '已入库存',
    prop: 'qty',
    change: true
  }
])

const tableHeader4 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo',
    change: true
  },
  {
    label: '材料类型',
    prop: 'mtlType',
    change: true
  },
  {
    label: '材料名称',
    prop: 'mtlName',
    change: true,
    start: true
  },
  {
    label: '规格',
    prop: 'mtlSpec',
    change: true
  },
  {
    label: '颜色',
    prop: 'mtlColor',
    change: true
  },
  {
    label: '单位',
    prop: 'mtlUnit',
    change: true
  },
  {
    label: '毛重',
    prop: 'grossWeight',
    change: true
  },
  {
    label: '净重',
    prop: 'netWeight',
    change: true
  }
])

const tableHeader15 = ref([
  {
    label: '编码',
    prop: 'mtlNo',
    change: true
  },
  {
    label: '颜色',
    prop: 'mtlColor',
    change: true
  },
  {
    label: '材料名称',
    prop: 'mtlName',
    change: true,
    start: true
  },
  {
    label: '规格',
    prop: 'mtlSpec',
    change: true
  },
  {
    label: '单位',
    prop: 'mtlUnit',
    change: true
  }
])
</script>

<style lang="less" scoped>
.main {
  width: 100%;
  background-color: white;
}

.btns {
  display: flex;
  padding: 10px 35px 5px;
  justify-content: end;

  .bg {
    background-color: #e7e7e7;
    border: 1px solid #e7e7e7;
    color: #000000;
  }
}
</style>
